//package com.jichaoyun.sys.controller;
//
//
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.jichaoyun.common.model.Result;
//import com.jichaoyun.model.entity.*;
//import com.jichaoyun.model.vo.AlarmVo;
//
//import com.jichaoyun.model.vo.LimitAlarmVo;
//
//
//import com.jichaoyun.sys.service.*;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@RestController
//@Api(tags = {"报警信息接口"})
//@RequestMapping("/sys/AlarmInfo")
//public class AlarmController {
//
//    @Autowired
//    private PowerAlarmService powerAlarmService;
//
//    @Autowired
//    private LimitAlarmService limitAlarmService;
//
//    @Autowired
//    private DcAlarmService dcAlarmService;
//
//    @Autowired
//    private DoorOpenAlarmService doorOpenAlarmService;
//
//    @Autowired
//    private ComErrAlarmService comErrAlarmService;
//
//    @Autowired
//    private ParaAlarmService paraAlarmService;
//
//    @Autowired
//    private IBalanceAlarmService balanceAlarmService;
//
//    @Autowired
//    private ValveAlarmService valveAlarmService;
//
//    @ApiOperation("报警通知，轮询接口")
//    @GetMapping("/getStationAlarmInfo")
//    public Result<List<Map<String,Object>>> getStationAlarmInfo(Integer userId) {
//        List<Map<String,Object>> resList = new ArrayList<>();
//        resList.addAll(comErrAlarmService.pollingDb(userId));
//        resList.addAll(dcAlarmService.pollingDb(userId));
//        resList.addAll(doorOpenAlarmService.pollingDb(userId));
//        resList.addAll(balanceAlarmService.pollingDb(userId));
//        resList.addAll(limitAlarmService.pollingDb(userId));
//        resList.addAll(paraAlarmService.pollingDb(userId));
//        resList.addAll(powerAlarmService.pollingDb(userId));
//        resList.addAll(valveAlarmService.pollingDb(userId));
//        return Result.success(resList);
//    }
//
//
//    @ApiOperation(value = "报警通知，报警信息已读接口",notes = "只有超限报警需要传Info（例如：频率下限报警），其他报警Info传空值即可")
//    @PostMapping("/updateAlarmRead")
//    public Result<Void> updateAlarmRead(Integer id,String alarmInfo,Integer userId) {
//
//        switch (alarmInfo){
//            case "通讯报警":comErrAlarmService.MakeAlarmRead(id,userId);break;
//            case "直流报警":dcAlarmService.MakeAlarmRead(id,userId);break;
//            case "门开报警":doorOpenAlarmService.MakeAlarmRead(id,userId);break;
//            case "余额报警":balanceAlarmService.MakeAlarmRead(id,userId);break;
//            case "超限报警":limitAlarmService.MakeAlarmRead(id,userId);break;
//            case "仪表组态报警":paraAlarmService.MakeAlarmRead(id,userId);break;
//            case "断电报警":powerAlarmService.MakeAlarmRead(id,userId);break;
//            case "阀门报警":valveAlarmService.MakeAlarmRead(id,userId);break;
//        }
//        return Result.success(null);
//    }
//    @ApiOperation(value = "报警通知，报警信息全部已读已读接口")
//    @PostMapping("/updateAlarmReadByUserId")
//    public Result<Void> updateAllAlarmRead(Integer userId) {
//        comErrAlarmService.MakeAlarmRead(userId);
//        dcAlarmService.MakeAlarmRead(userId);
//        doorOpenAlarmService.MakeAlarmRead(userId);
//        balanceAlarmService.MakeAlarmRead(userId);
//        limitAlarmService.MakeAlarmRead(userId);
//        paraAlarmService.MakeAlarmRead(userId);
//        powerAlarmService.MakeAlarmRead(userId);
//        valveAlarmService.MakeAlarmRead(userId);
//        return Result.success(null);
//    }
//
//
//    @ApiOperation("报警信息，断电报警用户，查询站点断电报警情况")
//    @GetMapping("/getStationPowerAlarm")
//    public Result<Map<String, List<PowerAlarm>>> getStationPowerAlarm(Integer station, String date) {
//        return Result.success(powerAlarmService.getPowerAlarmInfo(station,date));
//    }
//
//    @ApiOperation(value = "报警信息，断电报警用户，导出断电报警表，导出到Excel")
//    @GetMapping("/DownloadPowerAlarm")
//    public void DownloadPowerAlarm(String line_name, String date, HttpServletResponse response) throws IOException {
//
//        powerAlarmService.getAlarmExcel(line_name,date,response);
//    }
//
//    @ApiOperation("报警信息，超限报警用户，查询站点超限报警情况")
//    @GetMapping("/getStationLimitAlarm")
//    public Result<Map<String, List<LimitAlarm>>> getStationLimitAlarm(Integer station, String date, String info) {
//        return Result.success(limitAlarmService.getLimitAlarmInfo(station,date,info));
//    }
//
//    @ApiOperation(value = "报警信息，超限报警用户，超限报警表，导出到Excel")
//    @GetMapping("/DownloadLimitAlarm")
//    public void DownloadLimitAlarm(String line_name, String date, HttpServletResponse response) throws IOException {
//
//        limitAlarmService.getAlarmExcel(line_name,date,response);
//    }
//    @ApiOperation("报警信息，直流报警用户，查询站点直流报警情况")
//    @GetMapping("/getStationDcAlarm")
//    public Result<Map<String, List<DcAlarm>>> getStationDcAlarm(Integer station, String date) {
//        return Result.success(dcAlarmService.getDcAlarmInfo(station,date));
//    }
//
//    @ApiOperation(value = "报警信息，直流报警用户，直流报警表，导出到Excel")
//    @GetMapping("/DownloadDcAlarm")
//    public void DownloadDcAlarm(String line_name, String date, HttpServletResponse response) throws IOException {
//
//        dcAlarmService.getAlarmExcel(line_name,date,response);
//    }
//
//    @ApiOperation("报警信息，门开报警用户，查询站点门开报警情况")
//    @GetMapping("/getStationDoorOpenAlarm")
//    public Result<Map<String, List<DoorOpenAlarm>>> getStationDoorOpenAlarm(Integer station, String date) {
//        return Result.success(doorOpenAlarmService.getDoorOPenAlarmInfo(station,date));
//    }
//
//    @ApiOperation(value = "报警信息，门开报警用户，门开报警表，导出到Excel")
//    @GetMapping("/DownloadDoorOPenAlarm")
//    public void DownloadDoorOPenAlarm(String line_name, String date, HttpServletResponse response) throws IOException {
//
//        doorOpenAlarmService.getAlarmExcel(line_name,date,response);
//    }
//    @ApiOperation("报警信息，通讯报警用户，查询站点通讯中断报警情况")
//    @GetMapping("/getStationComErrAlarm")
//    public Result<Map<String, List<ComErrAlarm>>> getStationComErrAlarm(Integer station, String date) {
//        return Result.success(comErrAlarmService.getComErrAlarmInfo(station,date));
//    }
//    @ApiOperation(value = "报警信息，通讯报警用户，通讯报警表，导出到Excel")
//    @GetMapping("/DownloadComErrAlarm")
//    public void DownloadComErrAlarm(String line_name, String date, HttpServletResponse response) throws IOException {
//
//        comErrAlarmService.getAlarmExcel(line_name,date,response);
//    }
//    @ApiOperation("报警信息，仪表组态报警用户，查询站点仪表组态报警情况")
//    @GetMapping("/getStationParaAlarm")
//    public Result<Map<String, List<ParaAlarm>>> getStationParaAlarm(Integer station, String date) {
//        return Result.success(paraAlarmService.getParaAlarmInfo(station,date));
//    }
//
//    @ApiOperation(value = "报警信息，仪表组态报警用户，仪表组态报警表，导出到Excel")
//    @GetMapping("/DownloadParaAlarm")
//    public void DownloadParaAlarm(String line_name, String date, HttpServletResponse response) throws IOException {
//
//        paraAlarmService.getAlarmExcel(line_name,date,response);
//    }
//
//    @ApiOperation("报警信息，断电报警用户，查询各线路断电报警情况")
//    @GetMapping("/getLinePowerAlarmInfo")
//    public Result<Map<String,Object>> getLinePowerAlarmInfo(String line_name, String date, Integer pageNo) {
//        IPage<List<AlarmVo>> res = powerAlarmService.getPowerAlarm(line_name,date,pageNo);
//        Map<String,Object> map = new HashMap<>();
//        map.put("records",res.getRecords());
//        map.put("total",res.getTotal());
//        map.put("pages",res.getPages());
//        return Result.success(map);
//    }
//
//    @ApiOperation("报警信息，超限报警用户，查询各线路超限报警情况")
//    @GetMapping("/getLineLimitAlarmInfo")
//    public Result<Map<String,Object>> getLineLimitAlarmInfo(String line_name, String date, Integer pageNo) {
//        IPage<List<LimitAlarmVo>> res = limitAlarmService.getLimitAlarm(line_name,date,pageNo);
//        Map<String,Object> map = new HashMap<>();
//        map.put("records",res.getRecords());
//        map.put("total",res.getTotal());
//        map.put("pages",res.getPages());
//        return Result.success(map);
//    }
//
//    @ApiOperation("报警信息，直流报警用户，查询各线路直流报警情况")
//    @GetMapping("/getLineDcAlarmInfo")
//    public Result<Map<String,Object>> getLineDcAlarmInfo(String line_name, String date, Integer pageNo) {
//        IPage<List<AlarmVo>> res = dcAlarmService.getDcAlarmAlarm(line_name,date,pageNo);
//        Map<String,Object> map = new HashMap<>();
//        map.put("records",res.getRecords());
//        map.put("total",res.getTotal());
//        map.put("pages",res.getPages());
//        return Result.success(map);
//    }
//
//    @ApiOperation("报警信息，门开报警用户，查询各线路门开报警情况")
//    @GetMapping("/getLineDoorOpenAlarmInfo")
//    public Result<Map<String,Object>> getLineDoorOpenAlarmInfo(String line_name, String date, Integer pageNo) {
//        IPage<List<AlarmVo>> res = doorOpenAlarmService.getDoorOpenAlarm(line_name,date,pageNo);
//        Map<String,Object> map = new HashMap<>();
//        map.put("records",res.getRecords());
//        map.put("total",res.getTotal());
//        map.put("pages",res.getPages());
//        return Result.success(map);
//    }
//
//    @ApiOperation("报警信息，通讯报警用户，查询各线路通讯中断报警情况")
//    @GetMapping("/getLineComErrAlarmInfo")
//    public Result<Map<String,Object>> getLineComErrAlarmInfo(String line_name, String date, Integer pageNo) {
//        IPage<List<AlarmVo>> res = comErrAlarmService.getComErrAlarm(line_name,date,pageNo);
//        Map<String,Object> map = new HashMap<>();
//        map.put("records",res.getRecords());
//        map.put("total",res.getTotal());
//        map.put("pages",res.getPages());
//        return Result.success(map);
//    }
//
//    @ApiOperation("报警信息，仪表组态报警用户，查询各线路仪表组态报警情况")
//    @GetMapping("/getParaAlarmInfo")
//    public Result<Map<String,Object>> getParaAlarmInfo(String line_name, String date, Integer pageNo) {
//        IPage<List<AlarmVo>> res = paraAlarmService.getParaAlarm(line_name,date,pageNo);
//        Map<String,Object> map = new HashMap<>();
//        map.put("records",res.getRecords());
//        map.put("total",res.getTotal());
//        map.put("pages",res.getPages());
//        return Result.success(map);
//    }
//}
